@extends('default.mobile.layouts.personalPublic')
@section('title','职位收藏夹-'.Site::get('webname'))
{{--首页css--}}
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/mobile/personal/common.css')}}">
@endsection
{{--头部标签--}}
@section('tag','职位收藏夹')

{{--主体内容--}}
@section('content')
    <!-- B 职位列表-->
    <div class="list_box">
        @if(count($favorites) > 0)
            @foreach($favorites as $v)
                <div class="list_info">
                    <a href="{{url('mobile/jobinfo_'.idEncryption($v->job_id).'.html')}}" data-id="{{$v->id}}">
                        <dl>
                            <dt><span class="title">{{$v->job_title}}</span><time>{{$v->created_at}}</time></dt>
                            <dd class="line">
                                <span class="money">@if($v->salary_above){{$v->salary_above}}-{{$v->salary_below}}元@else面试@endif</span>
                                <span class="status">
                                    @if($v->status)<span class="have">已投递</span>@else<span class="no">未投递</span>@endif
                                </span>
                            </dd>
                            <dd>
                                <span class="company">{{$v->company_name}}</span>
                                <span class="area">{{$v->location1}}</span>
                            </dd>
                        </dl>
                    </a>
                    <div class="del"><div>删除</div></div>
                </div>
            @endforeach
        @else
            <div class="list_empty">
                <span class="norecord"></span>
                <span class="sorry">抱歉，没有找到符合您条件记录！</span>
            </div>
        @endif

    </div>
    <!-- E 职位列表-->

    <!-- B分页 -->
    <div class="page">
        @if($favorites->currentPage() <= 1)
            <a class="btn_gary previous ">上一页</a>
        @else
            <a href="{{$favorites->previousPageUrl()}}" class="previous">上一页</a>
        @endif
        <span><em>{{$favorites->currentPage()}}</em>/{{$favorites->lastPage()}}</span>
        @if($favorites->currentPage()  ==  $favorites->lastPage())
            <a class="next btn_gary">下一页</a>
        @else
            <a href="{{$favorites->nextPageUrl()}}" class="next">下一页</a>
        @endif
    </div>
    <!-- E分页 -->
@endsection

@section('footerjs')
    @parent
    <script type="text/javascript" src="{{asset('/default/js/mobile/jquery/jquery.long_press.js')}}"></script>
    <script>
        var _token = '{{csrf_token()}}';
        $(function(){
//            $('.list_box').find('.list_info').each(function(){
//                var id = $(this).find('.list_info a').attr('data-id');
//                $(this).long_press({
//                    post_url:'/mobile/personal/favorites_curr_del',
//                    redirect_url:'/mobile/personal/favorites',
//                    select_title:'您确定要删除这个职位收藏记录吗？',
//                    id:id
//                });
//            });

            //$('.list_info')鼠标左滑右滑的时候触发
            $('.list_info').touchWipe({itemDelete: '.del'});

            //删除
            $('.del').on('click',function(){
                var that = this;
                var id = $(this).parents('.list_info').find('.list_info a').attr('data-id');
                layer.open({
                    content: '您确定要删除这个职位收藏记录吗？'
                    ,btn: ['确定', '取消']
                    ,yes: function(){
                        $.post("{{url('/mobile/personal/favorites_curr_del')}}", {'_token': "{{csrf_token()}}",'id':id}, function(data){

                            if(data.status == 200){
                                $(that).parents('.list_info').remove();
                                layerMsg(data.message,1);
                            }else{
                                layerMsg(data.message,1);
                            }
                        });
                    }
                });
            });
        });
    </script>
@endsection